package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.FdsCleaningRulesetService;
import com.yunhai.model.entity.fds.FdsCleaningRulesetEntity;
import com.yunhai.model.vo.fds.FdsCleaningRulesetQuery;
import com.yunhai.model.vo.fds.FdsCleaningRulesetVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/fdsCleaningRuleset")
public class FdsCleaningRulesetController {

	@Resource
	private FdsCleaningRulesetService fdsCleaningRulesetService;


	/**
	 * 获取 FdsCleaningRuleset 分页列表
	 */
	@GetMapping("/pagination")
	public Ret getFdsCleaningRulesetPagination(PaginationVo paginationVo, FdsCleaningRulesetQuery fdsCleaningRulesetQuery ) throws Exception {
		IPage page = fdsCleaningRulesetService.getFdsCleaningRulesetPagination(paginationVo, fdsCleaningRulesetQuery );
		return Ret.toPage(page);
	}


	/**
	 * 获取 FdsCleaningRuleset 所有数据
	 */
	@GetMapping("/allList")
	public Ret getFdsCleaningRulesetAllList( FdsCleaningRulesetQuery fdsCleaningRulesetQuery ) throws Exception {
		List<FdsCleaningRulesetEntity> list = fdsCleaningRulesetService.getFdsCleaningRulesetAllList( fdsCleaningRulesetQuery );
		return Ret.ok(list);
	}


	/**
	 * 获取 FdsCleaningRuleset 详情
	 */
	@GetMapping("/{id}")
	public Ret getFdsCleaningRulesetDetailById(@PathVariable Long id) throws Exception {

	    FdsCleaningRulesetEntity fdsCleaningRulesetEntity = fdsCleaningRulesetService.getFdsCleaningRulesetDetail(id);
		return Ret.ok(fdsCleaningRulesetEntity);
	}


	/**
	 * 新增 FdsCleaningRuleset
	 * */
	@PostMapping("")
	public Ret addFdsCleaningRuleset(@RequestBody FdsCleaningRulesetVo fdsCleaningRulesetVo) throws Exception {

		fdsCleaningRulesetService.addFdsCleaningRuleset(fdsCleaningRulesetVo);
		return Ret.ok();
	}


	/**
	 * 更新 FdsCleaningRuleset
	 * */
	@PutMapping("")
	public Ret updateFdsCleaningRuleset(@RequestBody FdsCleaningRulesetVo fdsCleaningRulesetVo) throws Exception {

		fdsCleaningRulesetService.updateFdsCleaningRuleset(fdsCleaningRulesetVo);
		return Ret.ok();
	}


	/**
	 * 删除 FdsCleaningRuleset
	 * */
	@PostMapping("/batchRemove")
	public Ret batchRemoveFdsCleaningRuleset( @RequestBody List<Long> ids ) throws Exception {

	    fdsCleaningRulesetService.batchRemoveFdsCleaningRuleset(ids);
		return Ret.ok();
	}
}
